package com.yanqu.road.server.cmd.activity.fivehero;

import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.FiveHeroProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.gameplayer.module.player.PreReduceModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.property.PropertyHelper;

@Cmd(code = GameProtocol.S_FIVEHERO_REVIVE_PATRONS_FROM_CROSS, desc = "")
public class CrossFiveHeroRevivePatronsCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        FiveHeroProto.FiveHeroRevivePatronsRespMsg respMsg = FiveHeroProto.FiveHeroRevivePatronsRespMsg.parseFrom(packet.getBytes());
        player.getModule(PreReduceModule.class).restorePreReduce(respMsg.getCost());
        if(respMsg.getRet() == 0){
            player.getModule(CurrencyModule.class).removeCurrency(
                    PropertyHelper.parseStringToProperty(respMsg.getCost()),
                    eLogMoneyType.FiveHero,eLogMoneyType.FiveHeroRevivePatronsCost);
        }
        player.sendPacket(ClientProtocol.U_FIVEHERO_REVIVE_PATRONS, respMsg.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {

        }
    }
}
